<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>会员管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" method="post" action="/member/export">
	<blockquote class="layui-elem-quote quoteBox">
			<div class="layui-inline">
				<label class="layui-input-inline">微信昵称：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="nickName" name="nickName" placeholder="请输入微信昵称" />
				</div>
				<label class="layui-input-inline">中文名：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="name" name="name" placeholder="请输入中文名" />
				</div>
				<label class="layui-input-inline">手机号：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="phone" name="phone" placeholder="请输入手机号" />
				</div>
				<a class="layui-btn search_btn" data-type="reload">搜索</a>
			</div>
	</blockquote>
</form>
	<table id="entityList" lay-filter="entityList"></table>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;

        //列表
        var tableIns = table.render({
            elem: '#entityList',
            url : '/member/JsonList',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limit : 20,
            method:'post',
            limits : [10,15,20,25],
            id : "entityList",
            cols : [[
                {field: 'nickName', title: '微信昵称',align:'center',width:160},
                {field: 'cardNo', title: '会员编号',align:'center'},
                {field: 'type', title: '渠道类型',align:'center',templet:function(d){
                    if(d.type=="2"){
                        return "公司";
                    }else {
                        return "个人";
                    }
                },width:100},
                {field: 'name', title: '中文名',align:'center'},
                {field: 'englishName', title: '英文名',align:'center'},
                {field: 'sex', title: '性别',align:'center',templet:function(d){
                    if(d.sex=="2"){
                        return "女";
                    }else {
                        return "男";
                    }
                },width:100},
                {field: 'phone', title: '手机号',align:'center'},
                {field: 'wechat', title: '微信号',align:'center'},
                {field: 'bank', title: '开户行',align:'center'},
                {field: 'accountName', title: '账户名', align:'center',width:180},
                {field: 'accountNum', title: '账号', align:'center',width:180},
                {field: 'createTime', title: '创建时间', align:'center',width:180, templet:function(d){
                    return d.createtime;
                }}
            ]]
        });

        //搜索
        $(".search_btn").on("click",function(){
            table.reload("entityList",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    nickName: $("#nickName").val(),
                    name: $("#name").val(),
                    phone: $("#phone").val()
                }
            })
        });
        //增加/编辑
        function addEntity(params){
            var title="编辑";
            if(params==null||params==""){
                title="添加"
            }
            var index = layui.layer.open({
                title :title,
                type : 2,
                content : "/member/SelectEntity"+params,
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    body.find(".closeLay").bind("click",function () {
                        layui.layer.close(index);
                    })
                    layui.layer.full(index);
                }
            });
        }
        $(".add_btn").click(function(){
            addEntity('');
        })

        //列表操作
        table.on('tool(entityList)', function(obj){
            var layEvent = obj.event,
                data = obj.data;
            if(layEvent === 'edit'){ //编辑
                addEntity("?id="+data.id);
            } else if(layEvent === 'address'){ //地址信息
                window.location.href="/address/listPage?memberId="+data.id;
            } else if(layEvent === 'gradeEdit'){//收货员设置
                // 弹窗
                var index = layui.layer.open({
                    title :"级别设置",
                    type : 2,
                    content : "/member/memberGradeSet?memberId="+data.id+"&grade="+data.grade,
                    success : function(layero, index){
                        var body = layui.layer.getChildFrame('body', index);
                        body.find(".closeLay").bind("click",function () {
                            layui.layer.close(index);
                        })
                        //layui.layer.full(index);
                    }
                });
            }else if(layEvent === 'setData'){//设置数据
                // 弹窗
                var index = layui.layer.open({
                    title :"关联信息",
                    type : 2,
                    content : "/member/memberLinkNews?memberId="+data.id,
                    success : function(layero, index){
                        var body = layui.layer.getChildFrame('body', index);
                        body.find(".closeLay").bind("click",function () {
                            layui.layer.close(index);
                        })
                        layui.layer.full(index);
                    }
                });

            }
        });

    })
</script>
</body>
</html>